package observer.a;

public class CurrentConditionsDisplay implements Observer, DisplayElement {
	
	private Subject subject;
	
	private WeatherDataObject data;
	
	public CurrentConditionsDisplay(Subject subject) {
		this.subject = subject;
		subject.registerObserver(this);
	}

	public void update(Subject subject,Object data) {
		
		if (data instanceof WeatherDataObject) {
			WeatherDataObject wdata = (WeatherDataObject)data;
			this.data = wdata;
		}
		
		display();
	}

	public void display() {
		System.out.println("show weather---> temperature:"+data.getTemperature()+
				"; humidity:"+data.getHumidity()+"; pressure:"+data.getPressure());
	}

}
